<template>
  <div class="search">
    <f-form ref="form" :action="api.project" :form-key="this.formItem.projectId" >
      <f-form-item label="项目编码"  name="projectCode" required="true"    :value="formItem.projectCode" read-only />
      <f-form-item label="项目名称"  name="projectName"   required="true" :value="formItem.projectName" read-only/>
      <f-form-item label="项目地址"  name="projectAddress" required="true"   :value="formItem.projectAddress" read-only/>
      <f-form-item label="项目采购岗"  name="projectCgg"    :value="formItem.projectCgg" read-only/>
      <f-form-item label="项目商务岗"  name="projectSwg"    :value="formItem.projectSwg" read-only/>
      <f-form-item label="项目财务"  name="projectCwg"    :value="formItem.projectCwg" read-only/>
      <f-form-item label="项目经理"  name="projectXm"    :value="formItem.projectXm" read-only/>
      <f-form-item label="物资采购"  name="suppliesCg"    :value="formItem.suppliesCg" read-only/>
      <f-form-item label="商务岗采购"  name="businessCg"    :value="formItem.businessCg" read-only/>
      <f-form-item label="项目联系人"  name="projectLinkMan"    :value="formItem.projectLinkMan" read-only/>
      <f-form-item label="项目人电话"  :rules="rules.mobile" name="linkTel"    :value="formItem.linkTel" read-only/>
      <f-form-item label="项目联系人"  name="linkEmail"    :value="formItem.linkEmail" read-only/>
      <f-form-item label="材料员"  name="materialsLinkMan"    :value="formItem.materialsLinkMan" read-only/>
      <f-form-item label="材料员电话" :rules="rules.mobile" name="materialsTel"    :value="formItem.materialsTel" read-only/>
      <f-form-item label="材料员邮箱" :rules="rules.email" name="materialsEmail"    :value="formItem.materialsEmail" read-only/>
      <f-form-item label="收货员名称"  name="deliveryLinkMan"    :value="formItem.deliveryLinkMan" read-only />
      <f-form-item label="收货员电话"  :rules="rules.mobile" name="deliveryTel"    :value="formItem.deliveryTel" read-only/>
      <f-form-item label="收货员邮箱"  :rules="rules.email" name="deliveryEmai"     :value="formItem.deliveryEmai" read-only />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'projectForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          projectId: '',
          projectCode: '',
          projectName: '',
          versionId: '',
          useId: '',
          state: '',
          createTime: '',
          updateTime: '',
          projectAddress: '',
          projectCgg: '',
          projectSwg: '',
          projectCwg: '',
          projectXm: '',
          suppliesCg: '',
          businessCg: '',
          projectLinkMan: '',
          linkTel: '',
          linkEmail: '',
          materialsLinkMan: '',
          materialsTel: '',
          materialsEmail: '',
          deliveryLinkMan: '',
          deliveryTel: '',
          deliveryEmai: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.projectId) {
          let params={
              projectId:data.projectId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem = data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
